package hello.service;

import java.util.*;

/**
 * Created by Intellige Idea.
 * Author hiberk
 * Date 2017/5/23 10:11
 */
public class SonClass extends BaseClass {

    public SonClass() {
        super("123");
        this.test =1 ;
        System.out.println("this is son constructor" + test);
    }

    public String superName = "son";

    private int maxHit = 1000;

    private int test;

    private static int count = 100;

    public int getMaxHit() {
        return maxHit;
    }

    public void setMaxHit(int maxHit) {
        this.maxHit = maxHit;
    }



    private String name = "masan";

    @Override
    public String getName() {
        System.out.println(name);
        return name;
    }

    @Override
    public void setName(String name) {
        this.name = name;
    }

    static{
        System.out.println("this is son static block");
    }

    {
        System.out.println("this is son block");
    }


    public static void package0_1() {
        int[] vi = new int[]{2,3,5,1,5}; //可选物品列表的价值
        int[] wi = new int[]{2,3,3,4,4}; //可选物品列表的重量
        int weight = 10;
        //定义一个二位数组，第一个坐标表示可选的物品价值。第二个表示重量。这个数组存放每一个条件的最大值
        int[][] value = new int[vi.length][weight+1];
        for (int i=1;i<vi.length;i++) {
            for (int j=0;j<=weight;j++) {
                if (wi[i]>j || j==0) {
                    value[0][j] = 0;
                    value[i][j] = value[i-1][j];
                } else {
                                    //这个二位数组当前值等于上一个值(不放第I个物品的最大值 和放入第i个物品后的值 )  取最大
                                    //如果要放入第i个物品，那么要保证重量没有超出，所以要减去 i物品的重量 然后 加上 i物品的价值
                    value[i][j] = Math.max(value[i-1][j], value[i-1][j - wi[i]] + vi[i]);
                }
            }
        }

        System.out.println(value[4][10]);
    }

    public void out() {
        System.out.println("this is son class");
    }

    public static void main(String[] args) {
        int counter = 1;
//        BaseClass a = new SonClass();
        ArrayList<Integer> list = new ArrayList<Integer>(5);
        Set<BaseA> set1 = new TreeSet<BaseA>();
        String[] str = new String[]{"a","b","c","d"};
        List<String> list1 = new ArrayList<>(Arrays.asList(str));
        list1.add("e");
        list1.add("f");
        System.out.println(list1);
//        Collections.addAll(list,1,2,3,4,5);
        list.addAll(Arrays.asList(1,2,3,4,5));
        System.out.println(counter--);
        System.out.println(counter);
    }
}
